/*  
 *  Copyright 2006 Paul Jack.
 *
 *  This file is part of the Dex compiler suite. 
 *  
 *  Dex is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 2 of the License, or (at your
 *  option) any later version.
 *  
 *  Dex is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 *  Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
package dex.compiler.model.type;

import dex.misc.Augmented;


/**
 * The name of a basic type node.
 * 
 * <p>These names are cached so that every basic type node in a parse
 * tree uses the same instance for its name. 
 */
final public class BasicTypeName extends Augmented<BasicTypeName> {

	
	/**
	 * The name.
	 */
	private String name;
	
	
	/**
	 * Constructor.  Package protected to force people to go through a cache.
	 * 
	 * @param name  the name
	 */
	BasicTypeName(String name) {
		this.name = name;
	}


	/**
	 * Returns the name.
	 * 
	 * @return  the name
	 */
	@Override
	public String toString() {
		return name;
	}


	/**
	 * Returns true if the given object is the same as this name.
	 * 
	 * @return  true if the given object is the same as this name
	 */
	@Override
	public boolean equals(Object o) {
		if (!(o instanceof BasicTypeName)) {
			return false;
		}
		BasicTypeName n = (BasicTypeName)o;
		return n.name.equals(name);
	}


	/**
	 * Returns a hash code for this name.
	 * 
	 * @return a hash code for this name
	 */
	@Override
	public int hashCode() {
		return name.hashCode();
	}


}
